<?php
// for循环
for ($i = 1; $i <= 5; $i++) {
    echo "for循环：$i\n";
}

// while循环
$j = 1;
while ($j <= 5) {
    echo "while循环：$j\n";
    $j++;
}

// do-while循环
$k = 1;
do {
    echo "do-while循环：$k\n";
    $k++;
} while ($k <= 5);

// foreach循环（用于数组）
$fruits = ["苹果", "香蕉", "橙子"];
foreach ($fruits as $fruit) {
    echo "水果：$fruit\n";
}

// 带索引的foreach
foreach ($fruits as $index => $fruit) {
    echo "索引：$index, 水果：$fruit\n";
}
?>